home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 July: Mac OS SDK / Dev.CD Jul 00 SDK2.toast / Development Kits / Cross Platform / QuickTime 4.1.2 Windows SDK / CIncludes / LanguageAnalysis.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-12  |  11.5 KB  |  455 lines  |  [TEXT/R*ch]

  1. /*
  2.      File:        LanguageAnalysis.h
  3.  
  4.      Contains:    Language Analysis Manager Interfaces
  5.  
  6.      Version:    Technology:    Mac OS 8
  7.                  Release:    QuickTime 4.1
  8.  
  9.      Copyright:    (c) 1996, 1999 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __LANGUAGEANALYSIS__
  18. #define __LANGUAGEANALYSIS__
  19.  
  20. #ifndef __MACTYPES__
  21.     #include <MacTypes.h>
  22. #endif
  23.  
  24. #ifndef __FILES__
  25.     #include <Files.h>
  26. #endif
  27.  
  28. #ifndef __AEREGISTRY__
  29.     #include <AERegistry.h>
  30. #endif
  31.  
  32. #ifndef __DICTIONARY__
  33.     #include <Dictionary.h>
  34. #endif
  35.  
  36. #ifndef __TEXTCOMMON__
  37.     #include <TextCommon.h>
  38. #endif
  39.  
  40. #ifndef __MACERRORS__
  41.     #include <MacErrors.h>
  42. #endif
  43.  
  44.  
  45.  
  46.  
  47. #if PRAGMA_ONCE
  48. #pragma once
  49. #endif
  50.  
  51. #ifdef __cplusplus
  52. extern "C" {
  53. #endif
  54.  
  55. #if PRAGMA_IMPORT
  56. #pragma import on
  57. #endif
  58.  
  59. #if PRAGMA_STRUCT_ALIGN
  60.     #pragma options align=power
  61. #elif PRAGMA_STRUCT_PACKPUSH
  62.     #pragma pack(push, 2)
  63. #elif PRAGMA_STRUCT_PACK
  64.     #pragma pack(2)
  65. #endif
  66.  
  67. typedef struct OpaqueLAEnvironmentRef*     LAEnvironmentRef;
  68. typedef struct OpaqueLAContextRef*         LAContextRef;
  69. typedef AEKeyword                         LAPropertyKey;
  70. typedef DescType                         LAPropertyType;
  71. /*
  72.     Data structure for high level API
  73. */
  74.  
  75. struct LAMorphemeRec {
  76.     ByteCount                         sourceTextLength;
  77.     LogicalAddress                     sourceTextPtr;
  78.     ByteCount                         morphemeTextLength;
  79.     LogicalAddress                     morphemeTextPtr;
  80.     UInt32                             partOfSpeech;
  81. };
  82. typedef struct LAMorphemeRec            LAMorphemeRec;
  83.  
  84. struct LAMorphemesArray {
  85.     ItemCount                         morphemesCount;
  86.     ByteCount                         processedTextLength;
  87.     ByteCount                         morphemesTextLength;
  88.     LAMorphemeRec                     morphemes[1];
  89. };
  90. typedef struct LAMorphemesArray            LAMorphemesArray;
  91. typedef LAMorphemesArray *                LAMorphemesArrayPtr;
  92. enum {
  93.     kLAMorphemesArrayVersion    = 0
  94. };
  95.  
  96. /*
  97.     Definitions for result path/bundle structure
  98. */
  99.  
  100. typedef AERecord                         LAMorphemeBundle;
  101. typedef AERecord                         LAMorphemePath;
  102. typedef AERecord                         LAMorpheme;
  103. typedef AERecord                         LAHomograph;
  104. enum {
  105.     keyAELAMorphemeBundle        = FOUR_CHAR_CODE('lmfb'),
  106.     keyAELAMorphemePath            = FOUR_CHAR_CODE('lmfp'),
  107.     keyAELAMorpheme                = FOUR_CHAR_CODE('lmfn'),
  108.     keyAELAHomograph            = FOUR_CHAR_CODE('lmfh')
  109. };
  110.  
  111. enum {
  112.     typeLAMorphemeBundle        = typeAERecord,
  113.     typeLAMorphemePath            = typeAERecord,
  114.     typeLAMorpheme                = typeAEList,
  115.     typeLAHomograph                = typeAEList
  116. };
  117.  
  118. /*
  119.     Definitions for morpheme/homograph information
  120. */
  121. enum {
  122.     keyAEMorphemePartOfSpeechCode = FOUR_CHAR_CODE('lamc'),
  123.     keyAEMorphemeTextRange        = FOUR_CHAR_CODE('lamt')
  124. };
  125.  
  126. enum {
  127.     typeAEMorphemePartOfSpeechCode = FOUR_CHAR_CODE('lamc'),
  128.     typeAEMorphemeTextRange        = FOUR_CHAR_CODE('lamt')
  129. };
  130.  
  131. typedef UInt32                             MorphemePartOfSpeech;
  132.  
  133. struct MorphemeTextRange {
  134.     UInt32                             sourceOffset;
  135.     UInt32                             length;
  136. };
  137. typedef struct MorphemeTextRange        MorphemeTextRange;
  138. /*
  139.     Mask for High level API convert flags 
  140. */
  141. enum {
  142.     kLAEndOfSourceTextMask        = 0x00000001
  143. };
  144.  
  145. /*
  146.     Constants for leading/trailing path of analysis function
  147. */
  148. enum {
  149.     kLADefaultEdge                = 0,
  150.     kLAFreeEdge                    = 1,
  151.     kLAIncompleteEdge            = 2
  152. };
  153.  
  154. /*
  155.     Constants for confirm and shift function
  156. */
  157. enum {
  158.     kLAAllMorphemes                = 0
  159. };
  160.  
  161.  
  162. /*
  163.     Library version
  164. */
  165. EXTERN_API( UInt32 )
  166. LALibraryVersion                (void);
  167.  
  168. /*
  169.     High level API
  170. */
  171. EXTERN_API( OSStatus )
  172. LATextToMorphemes                (LAContextRef             context,
  173.                                  TextEncoding             preferedEncoding,
  174.                                  ByteCount                 textLength,
  175.                                  ConstLogicalAddress     sourceText,
  176.                                  ByteCount                 bufferSize,
  177.                                  OptionBits             convertFlags,
  178.                                  UInt32                 structureVersion,
  179.                                  ByteCount *            acceptedLength,
  180.                                  LAMorphemesArrayPtr     resultBuffer);
  181.  
  182. /*
  183.     Handling Context
  184. */
  185. EXTERN_API( OSStatus )
  186. LAOpenAnalysisContext            (LAEnvironmentRef         environ,
  187.                                  LAContextRef *            context);
  188.  
  189. EXTERN_API( OSStatus )
  190. LACloseAnalysisContext            (LAContextRef             context);
  191.  
  192. /*
  193.     Handling Environment
  194. */
  195. EXTERN_API( OSStatus )
  196. LAGetEnvironmentList            (UInt32                 maxCount,
  197.                                  UInt32 *                actualCount,
  198.                                  LAEnvironmentRef         environmentList[]);
  199.  
  200. EXTERN_API( OSStatus )
  201. LAGetEnvironmentName            (LAEnvironmentRef         environment,
  202.                                  Str63                     environmentName);
  203.  
  204. EXTERN_API( OSStatus )
  205. LAGetEnvironmentRef                (ConstStr63Param         targetEnvironmentName,
  206.                                  LAEnvironmentRef *        environment);
  207.  
  208. EXTERN_API( OSStatus )
  209. LACreateCustomEnvironment        (LAEnvironmentRef         baseEnvironment,
  210.                                  ConstStr63Param         newEnvironmentName,
  211.                                  Boolean                 persistent,
  212.                                  LAEnvironmentRef *        newEnvironment);
  213.  
  214. EXTERN_API( OSStatus )
  215. LADeleteCustomEnvironment        (LAEnvironmentRef         environment);
  216.  
  217. /*
  218.     Handling dictionries
  219. */
  220. EXTERN_API( OSStatus )
  221. LAOpenDictionary                (LAEnvironmentRef         environ,
  222.                                  const FSSpec *            dictionary);
  223.  
  224. EXTERN_API( OSStatus )
  225. LACloseDictionary                (LAEnvironmentRef         environ,
  226.                                  const FSSpec *            dictionary);
  227.  
  228. EXTERN_API( OSStatus )
  229. LAListAvailableDictionaries        (LAEnvironmentRef         environ,
  230.                                  ItemCount                 maxCount,
  231.                                  ItemCount *            actualCount,
  232.                                  FSSpec                 dictionaryList[],
  233.                                  Boolean                 opened[]);
  234.  
  235. EXTERN_API( OSStatus )
  236. LAAddNewWord                    (LAEnvironmentRef         environ,
  237.                                  const FSSpec *            dictionary,
  238.                                  const AEDesc *            dataList);
  239.  
  240. /*
  241.     Analyzing text
  242. */
  243. EXTERN_API( OSStatus )
  244. LAMorphemeAnalysis                (LAContextRef             context,
  245.                                  ConstUniCharArrayPtr     text,
  246.                                  UniCharCount             textLength,
  247.                                  LAMorphemePath *        leadingPath,
  248.                                  LAMorphemePath *        trailingPath,
  249.                                  ItemCount                 pathCount,
  250.                                  LAMorphemeBundle *        result);
  251.  
  252. EXTERN_API( OSStatus )
  253. LAContinuousMorphemeAnalysis    (LAContextRef             context,
  254.                                  ConstUniCharArrayPtr     text,
  255.                                  UniCharCount             textLength,
  256.                                  Boolean                 incrementalText,
  257.                                  LAMorphemePath *        leadingPath,
  258.                                  LAMorphemePath *        trailingPath,
  259.                                  Boolean *                modified);
  260.  
  261. EXTERN_API( OSStatus )
  262. LAGetMorphemes                    (LAContextRef             context,
  263.                                  LAMorphemePath *        result);
  264.  
  265. EXTERN_API( OSStatus )
  266. LAShiftMorphemes                (LAContextRef             context,
  267.                                  ItemCount                 morphemeCount,
  268.                                  LAMorphemePath *        path,
  269.                                  UniCharCount *            shiftedLength);
  270.  
  271. EXTERN_API( OSStatus )
  272. LAResetAnalysis                    (LAContextRef             context);
  273.  
  274. /*
  275.     Check Language Analysis Manager availability
  276. */
  277. #if TARGET_RT_MAC_CFM
  278. #ifdef __cplusplus
  279.     inline pascal Boolean LALanguageAnalysisAvailable() { return (LALibraryVersion != (void*)kUnresolvedCFragSymbolAddress); }
  280. #else
  281.     #define LALanguageAnalysisAvailable()     ((LALibraryVersion != (void*)kUnresolvedCFragSymbolAddress)
  282. #endif
  283. #elif TARGET_RT_MAC_MACHO
  284. /* Language Analysis Manager is always available on OS X */
  285. #ifdef __cplusplus
  286.     inline pascal Boolean LALanguageAnalysisAvailable() { return true; }
  287. #else
  288.     #define LALanguageAnalysisAvailable()     (true)
  289. #endif
  290. #endif  /*  */
  291.  
  292. /*
  293. =============================================================================================
  294.     Definitions for Japanese Analysis Module
  295. =============================================================================================
  296. */
  297. /*
  298.     Names for default environments for Japanese analysis
  299. */
  300. #define kLAJapaneseKanaKanjiEnvironment                "\pKanaKanjiConversion"
  301. #define kLAJapaneseMorphemeAnalysisEnvironment        "\pJapaneseMorphemeAnalysis"
  302. #define kLAJapaneseTTSEnvironment                    "\pJapaneseTextToSpeech"
  303. /*
  304.     File cretor for dictionary of Apple Japanese access method
  305. */
  306. enum {
  307.     kAppleJapaneseDictionarySignature = FOUR_CHAR_CODE('jlan')
  308. };
  309.  
  310. /*
  311.     Engine limitations
  312. */
  313. enum {
  314.     kMaxInputLengthOfAppleJapaneseEngine = 200
  315. };
  316.  
  317. /*
  318.     Definitions of information in the path/bundle
  319. */
  320.  
  321. typedef MorphemePartOfSpeech             JapanesePartOfSpeech;
  322. typedef UInt16                             HomographWeight;
  323. typedef UInt8                             HomographAccent;
  324. /*
  325.     AE keywords and type definitions for morpheme/homograph information
  326. */
  327. enum {
  328.     keyAEHomographDicInfo        = FOUR_CHAR_CODE('lahd'),
  329.     keyAEHomographWeight        = FOUR_CHAR_CODE('lahw'),
  330.     keyAEHomographAccent        = FOUR_CHAR_CODE('laha')
  331. };
  332.  
  333. enum {
  334.     typeAEHomographDicInfo        = FOUR_CHAR_CODE('lahd'),
  335.     typeAEHomographWeight        = typeShortInteger,
  336.     typeAEHomographAccent        = FOUR_CHAR_CODE('laha')
  337. };
  338.  
  339. /*
  340.     Structure for dictionary information of homograph
  341. */
  342.  
  343. struct HomographDicInfoRec {
  344.     DCMDictionaryID                 dictionaryID;
  345.     DCMUniqueID                     uniqueID;
  346. };
  347. typedef struct HomographDicInfoRec        HomographDicInfoRec;
  348. /*
  349. =============================================================================================
  350.     Definitions for Japanese part of speeches
  351. =============================================================================================
  352. */
  353. /*
  354.     Masks for part of speeches
  355. */
  356. enum {
  357.     kLASpeechRoughClassMask        = 0x0000F000,
  358.     kLASpeechMediumClassMask    = 0x0000FF00,
  359.     kLASpeechStrictClassMask    = 0x0000FFF0,
  360.     kLASpeechKatsuyouMask        = 0x0000000F
  361. };
  362.  
  363.  
  364. /*
  365.     Part of speeches
  366. */
  367. enum {
  368.     kLASpeechMeishi                = 0x00000000,                    /* noun */
  369.     kLASpeechFutsuuMeishi        = 0x00000000,                    /* general noun */
  370.     kLASpeechJinmei                = 0x00000100,                    /* person name */
  371.     kLASpeechJinmeiSei            = 0x00000110,                    /* family name */
  372.     kLASpeechJinmeiMei            = 0x00000120,                    /* first name */
  373.     kLASpeechChimei                = 0x00000200,                    /* place name */
  374.     kLASpeechSetsubiChimei        = 0x00000210,                    /* place name with suffix */
  375.     kLASpeechSoshikimei            = 0x00000300,                    /* organization name */
  376.     kLASpeechKoyuuMeishi        = 0x00000400,                    /* proper noun */
  377.     kLASpeechSahenMeishi        = 0x00000500,                    /* special noun */
  378.     kLASpeechKeidouMeishi        = 0x00000600,                    /* special noun */
  379.     kLASpeechRentaishi            = 0x00001000,
  380.     kLASpeechFukushi            = 0x00002000,                    /* adverb */
  381.     kLASpeechSetsuzokushi        = 0x00003000,                    /* conjunction */
  382.     kLASpeechKandoushi            = 0x00004000,
  383.     kLASpeechDoushi                = 0x00005000,                    /* verb */
  384.     kLASpeechGodanDoushi        = 0x00005000,
  385.     kLASpeechKagyouGodan        = 0x00005000,
  386.     kLASpeechSagyouGodan        = 0x00005010,
  387.     kLASpeechTagyouGodan        = 0x00005020,
  388.     kLASpeechNagyouGodan        = 0x00005030,
  389.     kLASpeechMagyouGodan        = 0x00005040,
  390.     kLASpeechRagyouGodan        = 0x00005050,
  391.     kLASpeechWagyouGodan        = 0x00005060,
  392.     kLASpeechGagyouGodan        = 0x00005070,
  393.     kLASpeechBagyouGodan        = 0x00005080,
  394.     kLASpeechIchidanDoushi        = 0x00005100,
  395.     kLASpeechKahenDoushi        = 0x00005200,
  396.     kLASpeechSahenDoushi        = 0x00005300,
  397.     kLASpeechZahenDoushi        = 0x00005400,
  398.     kLASpeechKeiyoushi            = 0x00006000,                    /* adjective */
  399.     kLASpeechKeiyoudoushi        = 0x00007000,
  400.     kLASpeechSettougo            = 0x00008000,                    /* prefix*/
  401.     kLASpeechSuujiSettougo        = 0x00008100,                    /* prefix for numbers */
  402.     kLASpeechSetsubigo            = 0x00009000,                    /* suffix */
  403.     kLASpeechJinmeiSetsubigo    = 0x00009100,                    /* suffix for person name */
  404.     kLASpeechChimeiSetsubigo    = 0x00009200,                    /* suffix for place name */
  405.     kLASpeechSoshikimeiSetsubigo = 0x00009300,                    /* suffix for organization name */
  406.     kLASpeechSuujiSetsubigo        = 0x00009400,                    /* suffix for numbers */
  407.     kLASpeechMuhinshi            = 0x0000A000,                    /* no category */
  408.     kLASpeechTankanji            = 0x0000A000,                    /* character */
  409.     kLASpeechKigou                = 0x0000A100,                    /* symbol */
  410.     kLASpeechKuten                = 0x0000A110,
  411.     kLASpeechTouten                = 0x0000A120,
  412.     kLASpeechSuushi                = 0x0000A200,                    /* numbers */
  413.     kLASpeechDokuritsugo        = 0x0000A300,
  414.     kLASpeechSeiku                = 0x0000A400,
  415.     kLASpeechJodoushi            = 0x0000B000,                    /* auxiliary verb */
  416.     kLASpeechJoshi                = 0x0000C000                    /* postpositional particle */
  417. };
  418.  
  419.  
  420. /*
  421.     Conjugations
  422.  */
  423. enum {
  424.     kLASpeechKatsuyouGokan        = 0x00000001,                    /* stem */
  425.     kLASpeechKatsuyouMizen        = 0x00000002,
  426.     kLASpeechKatsuyouRenyou        = 0x00000003,
  427.     kLASpeechKatsuyouSyuushi    = 0x00000004,
  428.     kLASpeechKatsuyouRentai        = 0x00000005,
  429.     kLASpeechKatsuyouKatei        = 0x00000006,
  430.     kLASpeechKatsuyouMeirei        = 0x00000007
  431. };
  432.  
  433.  
  434.  
  435. #if PRAGMA_STRUCT_ALIGN
  436.     #pragma options align=reset
  437. #elif PRAGMA_STRUCT_PACKPUSH
  438.     #pragma pack(pop)
  439. #elif PRAGMA_STRUCT_PACK
  440.     #pragma pack()
  441. #endif
  442.  
  443. #ifdef PRAGMA_IMPORT_OFF
  444. #pragma import off
  445. #elif PRAGMA_IMPORT
  446. #pragma import reset
  447. #endif
  448.  
  449. #ifdef __cplusplus
  450. }
  451. #endif
  452.  
  453. #endif /* __LANGUAGEANALYSIS__ */
  454.  
  455.